﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Light.Framework.Model;
using System.Data;
using Light.Utility;

namespace Light.Framework.Contract
{

    /// <summary>
    /// 组件接口
    /// </summary>
    public interface IComponent
    {
        Dictionary<string, string> SearchFields { get; }
        ModelOrder ModelOrder { get; }

        OperateResult Delete(int id);
        DataTable SearchTable(SearchArgs searchArgs, PageArgs pageArgs);

        int Count();
        int Count(SearchArgs args);
    }

    /// <summary>
    /// 组件基接口(泛型)
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IComponent<T> : IComponent where T : class, IEntity, new()
    {

        OperateResult Create(T obj);
        OperateResult Delete(T model);
        OperateResult Delete(IList<T> models);
        OperateResult Update(T obj);
        OperateResult Save(T obj);
        OperateResult Import(List<T> models);

        T Get();
        T Get(int id);
        T Get(SearchArgs args);
        T Get(string propertyName, object value);

        IList<T> GetAll();
        IList<T> GetAll(SearchArgs args);

        IList<T> Search(SearchArgs searchArgs, PageArgs pageArgs);
        IList<T> Search(SearchArgs args, int pageIndex, int pageSize, out int totalResult);
    }
}
